/* Given a sequence of length N, such as 32231132113231, we want to find two
 * cut-off points 0 <= j <= k <= N such that it takes the minimum number of
 * changes to set digits in [1,j] to 1 (or 3), digits in [j+1,k] to 2, and 
 * digits in [k+1,N] to 3 (or 1).
 *
 * A simple approach would be to check all combinations of j, k; however, 
 * this takes O(N^2) time and is too long.
 *
 * Alternatively, we describe a one-pass method with time complexity O(N).
 * Suppose we're at character k (1 <= k <= N), and we have already found the
 * optimal cut-off points for [1..k-1] for one and two cut-offs, respectively.
 * We first update the optimal single cut-off after including character k by
 * comparing the cost of cutting off after k with the previous optimal single
 * cut-off, and select the better one. Then we update the optimal double 
 * cut-off by evaluating the cost of adding the second cut-off after k to the
 * current optimal single-cutoff. If the cost is lower than the previous 
 * best two-cutoff, we use this one.
 */

#include <stdio.h>

#define Min(a,b) ((a) < (b) ? (a) : (b))

int main()
{
    int one_cut_best_12 = 0;  /* cost of optimal one-cut to form 1|2 */
    int one_cut_here_12 = 0;  /* cost of cutting here to form 1|2 */
    int two_cut_best_123 = 0; /* cost of optimal two-cut to form 1|2|3 */

    int one_cut_best_32 = 0;  /* cost of optimal one-cut to form 3|2 */
    int one_cut_here_32 = 0;  /* cost of cutting here to form 3|2 */
    int two_cut_best_321 = 0; /* cost of optimal two-cut to form 3|2|1 */

    int n, i;
    scanf("%d", &n);
    for (i = 1; i <= n; i++)
    {
        int digit;
        scanf("%d", &digit);

        /* assuming 123 */
        if (digit != 2)
            one_cut_best_12++;
        if (digit != 1)
            one_cut_here_12++;
        one_cut_best_12 = Min(one_cut_best_12, one_cut_here_12);

        if (digit != 3)
            two_cut_best_123++;
        two_cut_best_123 = Min(two_cut_best_123, one_cut_best_12);

        /* assuming 321 */
        if (digit != 2)
            one_cut_best_32++;
        if (digit != 3)
            one_cut_here_32++;
        one_cut_best_32 = Min(one_cut_best_32, one_cut_here_32);

        if (digit != 1)
            two_cut_best_321++;
        two_cut_best_321 = Min(two_cut_best_321, one_cut_best_32);
    }
    printf("%d\n", Min(two_cut_best_123, two_cut_best_321));
    return 0;
}
